home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Program Name: Stiletto */
- /* */
- /* File Name: About.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-06-30 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "Desk.h"
- #include "Fonts.h"
- #include "Resources.h"
- #include "ToolUtils.h"
-
- #include "About.h"
- #include "Constants.h"
- #include "Utilities.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define MAXLONG 0x7FFFFFFF
-
- /****************************************** PROTOTYPES ******************************************/
-
- PicHandle GetCenteredPict (short resID, const Rect * bounds, Rect * picFrame);
- void DoSomething (DialogPtr theDialog);
-
- /******************************************** GLOBALS *******************************************/
-
- extern ModalFilterUPP gAboutFilterUPP;
- extern UserItemUPP gDrawAboutPictUPP;
- extern UserItemUPP gDrawVersUPP;
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- #pragma segment About
- PicHandle GetCenteredPict (short resID, const Rect * bounds, Rect * picFrame)
- {
- PicHandle thePicture = GetPicture (resID);
-
- picFrame->top = (**thePicture).picFrame.top;
- picFrame->left = (**thePicture).picFrame.left;
- picFrame->right = (**thePicture).picFrame.right;
- picFrame->bottom = (**thePicture).picFrame.bottom;
-
- OffsetRect(picFrame, -picFrame->left, -picFrame->top);
-
- OffsetRect(picFrame, (bounds->right-bounds->left-picFrame->right) / 2,
- (bounds->bottom-bounds->top-picFrame->bottom) / 2);
-
- return (thePicture);
- }
-
-
- #pragma segment About
- pascal void DrawVers (DialogPtr theDialog, short itemNumber)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- VersRecHndl version;
-
- version = (VersRecHndl) GetResource ('vers', 1);
-
- GetDItem(theDialog, itemNumber, &itemKind, &itemHand, &itemRect);
-
- MoveTo (itemRect.left, itemRect.bottom);
- TextSize (9);
- TextFont (applFont);
- DrawString ((**version).shortVersion);
-
- ReleaseResource ((Handle) version);
- }
-
-
- #pragma segment About
- pascal void DrawAboutPict (DialogPtr theDialog, short itemNumber)
- {
- #pragma unused (itemNumber)
-
- Rect picFrame;
- PicHandle aboutPic;
-
- aboutPic = GetCenteredPict (rAboutPICT, &theDialog->portRect, &picFrame);
-
- DrawPicture(aboutPic, &picFrame);
-
- ReleaseResource ((Handle) aboutPic);
- }
-
-
- #pragma segment About
- void DoSomething (DialogPtr theDialog)
- {
- EventRecord theEvent;
- Boolean gotEvent = false;
-
- PaintRect (&theDialog->portRect);
-
- while (!gotEvent)
- {
- gotEvent = WaitNextEvent (mDownMask + keyDownMask, &theEvent, MAXLONG, nil);
- }
-
- EraseRect (&theDialog->portRect);
- InvalRect (&theDialog->portRect);
- }
-
-
- #pragma segment About
- pascal Boolean AboutFilterProc (DialogPtr theDialog, EventRecord * theEvent, short * itemHit)
- {
- Boolean wasHandled = false;
- char key;
- WindowPtr theWindow;
- static short index = 0;
- char *code = "chris";
-
- switch (theEvent->what) {
- case keyDown :
- key = theEvent->message & charCodeMask;
-
- if (key == code[index]) {
- index++;
- if (index == 5) {
- DoSomething (theDialog);
- index = 0;
- }
- }
- else
- index = 0;
-
- switch (key) {
- case crKey :
- case enterKey :
- *itemHit = kHitItem;
- wasHandled = true;
- break;
- }
- break;
-
- case mouseDown :
- switch (FindWindow(theEvent->where, &theWindow)) {
- case inDrag:
- DragWindow(theWindow, theEvent->where, &qd.screenBits.bounds);
- wasHandled = true;
- break;
- case inSysWindow:
- SystemClick(theEvent, theWindow);
- wasHandled = true;
- break;
- case inGoAway:
- if ( TrackGoAway(theWindow, theEvent->where) )
- HideWindow (theWindow);
- wasHandled = true;
- break;
- }
- break;
- }
-
- return (wasHandled);
- }
-
- #pragma segment About
- void DoAbout (void)
- {
- DialogPtr theDialog;
- short itemType;
- Handle item;
- Rect box;
- short itemHit;
-
- theDialog = GetNewDialog (rAboutDLOG, nil, (WindowPtr) (-1L));
- if (theDialog != nil) {
- SetPort (theDialog);
-
- GetDItem(theDialog, kPictItem, &itemType, &item, &box);
- SetDItem(theDialog, kPictItem, itemType, (Handle) gDrawAboutPictUPP, &box);
-
- GetDItem(theDialog, kVersItem, &itemType, &item, &box);
- SetDItem(theDialog, kVersItem, itemType, (Handle) gDrawVersUPP, &box);
-
- ShowWindow (theDialog);
-
- do
- ModalDialog (gAboutFilterUPP, &itemHit);
- while (itemHit != kHitItem);
-
- DisposeDialog (theDialog);
- }
- }